Software executing by a microcontroller can become unstable due to software bugs or running the microcontroller in environmental conditions outside a specified range (e.g., under voltage, clock spikes). Microcontrollers are used in embedded applications, where equipment can be stuck or permanently damaged (e.g. motors, halogen bulbs), if such malfunctioning software unintentionally writes to peripheral registers that control critical functions in the application. The two common failure types are runaway code, such as jumping to the wrong location in the program memory and a loose pointer which points to a wrong address in a data memory space.
Protection against unintended register modification has traditionally been handled locally within each peripheral component by some form of lock mechanism. For example, the need to write a key register to unlock access to another register. The exact mechanism is often specific to each peripheral component. The driver code for the peripheral component becomes more inefficient and complex because it needs to handle the unlocking. Typically, the driver will unlock the peripheral register immediately before modifying its contents, so inadvertent jumps to the driver code (runaway code) could result in writing a random value to the peripheral register. Sometimes only system-critical registers are protected to avoid over-complicating the driver. This solution leaves many registers and peripheral components without access protection. This is unfortunate since difference features can be critical in different systems. For example, a random write to a general purpose I/O (GPIO) port register can be fatal in one system but not in another, so it is normally not protected.